/*
 * @Author: limit
 * @Date: 2021-03-26 15:19:01
 * @LastEditTime: 2021-08-11 14:18:46
 * @LastEditors: limit
 * @FilePath: /basic-services/src/main.js
 * @Description: 由limit创建！
 */
import Vue from 'vue'
import Cookies from 'js-cookie'
import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

//引入苹方字体
import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control
// import '../public/UEditor/ueditor.config'
// import '../public/UEditor/ueditor.all.js'
//引入必要的文件 集成秀米所需
// import '../public/UEditor/dialogs/xiumi-ue-dialog-v5'
// import '../public/UEditor/dialogs/xiumi-ue-v5.css'
// 引入点击选择图标的插件
import iconPicker from 'e-icon-picker';
import 'e-icon-picker/lib/index.css'; //基础样式
// import 'e-icon-picker/dist/main.css'; //fontAwesome 图标库样式
Vue.use(iconPicker); //使用e-icon-picker
import moment from "moment";
Vue.filter('formatDate', function(value) {
    return moment(value).format('YYYY-MM-DD HH:mm')
})
import {
    localData,
    sessionData
} from "../src/utils/local"
Vue.prototype.localData = localData;
Vue.prototype.sessionData = sessionData;

import '@/directive/index';

// import VideoPlayer from 'vue-video-player'
// import 'vue-video-player/src/custom-theme.css'
// import 'video.js/dist/video-js.css'

// Vue.use(VideoPlayer)

// 引入dataV
// import dataV from '@jiaminghi/data-view';

// Vue.use(dataV)

//引入swiper轮播图插件
// import VueAwesomeSwiper from 'vue-awesome-swiper'
// // require styles
import "swiper/css/swiper.css";
// Vue.use(VueAwesomeSwiper, /* { default global options } */ )
// 引入富文本组件
import QuillEditor from 'vue-quill-editor'
// 引入富文本组件样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(QuillEditor)
console.log(QuillEditor);
// 富文本全局组件
import Editor from '@/components/Editor';
Vue.component("Editor", Editor);
Vue.use(ElementUI, {
    size: Cookies.get('size') || 'mini' // set element-ui default size
})
Vue.directive('color', {
    bind(el, binding, vnode) {
        el.style.color = "#" + Math.random().toString(16).slice(2, 8);
    }
})
Vue.directive('permission', {
        // 当被绑定的元素插入到 DOM 中时……
        inserted(el, binding, node) {
            const {
                code,
                show = true
            } = binding.value;
            const userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
            const roles = userInfo.permissions;
            if (roles.includes(code) && show) {
                return code;
            } else {
                el.parentNode && el.parentNode.removeChild(el)
            }
            //使用方式： v-permission="{ code: 'base:tenant:add' }"
            //"base:tenant:delete"删除  "base:tenant:export" 导出  "base:tenant:add" 增加 "base:tenant:update" //修改
        }
    })
    //动态设置页面title
    // 设置浏览器标题
Vue.directive('title', {
    inserted: function(el, binding) {
        document.title = el.dataset.title
    }
})

// 引入相关API接口
import API from '@/api/backgroud'
// 组件实例的原型的原型指向是vue.prototype
// 任意组件可以使用API相关接口
Vue.prototype.$API = API
    // set ElementUI lang to EN
    // Vue.use(ElementUI, { locale })
    // 如果想要中文版 element-ui，按如下方式声明
Vue.use(ElementUI)

Vue.config.productionTip = false

new Vue({
    el: '#app',
    router,
    store,
    render: h => h(App),
    // 全局事件总线$bus配置
    beforeCreate() {
        Vue.prototype.$bus = this
    },
})